﻿using Credisoft.Models;
using Credisoft.Models.Credisoft_BO;
using Credisoft.Models.Credisoft_DAO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Credisoft.Controllers.Prueba
{
    public class PruebaController : Controller
    {
        //
        // GET: /Prueba/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult UpdateMailbox2()
        {
            CreditGrantingDAO creditGrantingDAO = new CreditGrantingDAO();
            List<otorgamiento> grantingList = creditGrantingDAO.getCreditGrantingData();
            EnterpriseDAO enterpriseDAO = new EnterpriseDAO();
            List<EnterpriseBO> enterpriseBOList = new List<EnterpriseBO>();
            EconomicGroupDAO economicGroupDAO = new EconomicGroupDAO();
            List<EconomicGroupBO> economicGroupBOList = new List<EconomicGroupBO>();
            var objList = new List<object>();

            int j = 0;
            foreach (var i in grantingList)
            {
                //enterpriseBOList.Add(enterpriseDAO.getEnterpriseData((int)i.identidad));
                int groupId = enterpriseBOList.ElementAt(j).groupId;
               // economicGroupBOList.Add(economicGroupDAO.getEconomicGroupData(enterpriseBOList.ElementAt(j).groupId));
                var obj = new
                {
                    requestId = grantingList.ElementAt(j).idotorgamiento,
                    socialReason = enterpriseBOList.ElementAt(j).socialReason,
                    group = economicGroupBOList.ElementAt(j).name,
                    recordDate = grantingList.ElementAt(j).fecharegistro
                };
                j++;
                objList.Insert(0,obj);
            }
            //EnterpriseBO enterpriseBO = enterpriseDAO.getEnterpriseData((int)grantingList.identidad);
            //EconomicGroupBO economicGroupBO = economicGroupDAO.getEconomicGroupData(enterpriseBO.groupId);
            //var obj = new { requestId = grantingList.idsolicitud, socialReason = enterpriseBO.socialReason, group = economicGroupBO.name, recordDate = grantingList.fecharegistro};
            return Json(objList);
        }

    }
}
